package stancel.peter.smartsilencer.activities;

import java.text.SimpleDateFormat;
import java.util.Date;

import stancel.peter.smartsilencer.R;
import stancel.peter.smartsilencer.SmartSilencer;
import stancel.peter.smartsilencer.TimeAlarm;
import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

/**
 * Obsahuje informacie o aplikacii a autorovi.
 * @author Peter Stancel
 */
public class AboutActivity extends Activity{
	
	/**
	 * Vola sa pri vytvarani tejto aktivity.
	 * Vypise informacie o aplikacii a autorovi.
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.about);
		
		TextView textLog = (TextView) findViewById(R.id.about_log);
		SmartSilencer smartSilencer = (SmartSilencer) getApplication();
		StringBuilder stringBuilder = new StringBuilder();
		SimpleDateFormat sdf = new SimpleDateFormat();
		for (TimeAlarm timeAlarm : smartSilencer.loadDatesFromFile()) {
			stringBuilder.append(timeAlarm.getName() + ": " + sdf.format(timeAlarm.getDate().getTime()) + ", " + timeAlarm.isOneTime() + "\n");
		}
		Date date = new Date();
		stringBuilder.append(sdf.format(date));
		textLog.setText(stringBuilder);
	}
}
